package cn.elead.chaos.remote.web.system.controller;

import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.elead.chaos.framework.web.global.response.UnifiedReturn;
import cn.elead.chaos.mybatils.web.controller.BaseController;
import cn.elead.chaos.shiro.service.IShiroRealmService;
import cn.elead.chaos.sso.core.util.SsoUtils;

/**
 * Shiro权限远程服务
 * 
 * @author luopeng
 */
@UnifiedReturn
@RestController
@RequestMapping("/remote/system/shiro")
public class RemoteShiroController extends BaseController {

	@Autowired
	private IShiroRealmService shiroRealmService;

	/**
	 * 获取当前用户的角色
	 * 
	 * @param userId
	 * @return
	 */
	@GetMapping("/role")
	public Set<String> selectRoleKeys() {
		return shiroRealmService.selectRoleKeys(SsoUtils.getUserId());
	}

	/**
	 * 获取当前用户的权限
	 * 
	 * @return
	 */
	@GetMapping("/perms")
	public Set<String> selectPerms() {
		return shiroRealmService.selectPermsByUserId(SsoUtils.getUserId());
	}
}
